package com.cyru.statemachine.core.builder.impl;

import com.cyru.statemachine.core.StateMachineConfiguration;
import com.cyru.statemachine.core.builder.StateMachineConfigurationBuilder;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

/**
 * description:
 *
 * @author zhangxuchuan
 * date 2022/5/2
 */
public class StateMachineConfigurationBuilderImpl<S, E, C> implements StateMachineConfigurationBuilder<S, E, C> {

    private final StateMachineConfiguration<S, E, C> configuration;

    public StateMachineConfigurationBuilderImpl(StateMachineConfiguration<S, E, C> configuration) {
        this.configuration = configuration;
    }

    @SafeVarargs
    @Override
    public final StateMachineConfigurationBuilder<S, E, C> initStates(S... init) {
        Set<S> initStates = new HashSet<>(Arrays.asList(init));
        configuration.setInitStates(initStates);
        return this;
    }

    @SafeVarargs
    @Override
    public final StateMachineConfigurationBuilder<S, E, C> endStates(S... end) {
        Set<S> endStates = new HashSet<>(Arrays.asList(end));
        configuration.setEndStates(endStates);
        return this;
    }
}
